const http=require("http");

const server=http.createServer();

server.on("request",function(req,res){
    res.writeHead(200,{
        "Content-Type":"text/html;charset=utf8"
    });
    console.log("服务器被访问",req.url);
    res.write("Hello 中国");
    res.write("<h1>hello js</h1>");
    res.end();
});
server.listen(3000);
server.on("error",function(error){
    console.log("服务器运行错误");
    console.log(error);
});